﻿function getPrint(print_area) {

    //Creating new page

    //var pp = window.open('target-new=tab');
    var pp = window.open();

    //Adding HTML opening tag with <HEAD> … </HEAD> portion

    pp.document.writeln('<HTML><HEAD><title>Print Preview</title>')

    pp.document.writeln('<style type="text/css" media="print"> input {  display: none; } </style> ')

    pp.document.writeln('<base target="_self"></HEAD>')

    //Adding Body Tag

    pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0"');

    pp.document.writeln(' leftMargin="40" topMargin="0" rightMargin="0">');

    //Adding form Tag

    pp.document.writeln('<form method="post">');

    //Creating two buttons Print and Close within a HTML table

    pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right>');

    pp.document.writeln('<INPUT ID="PRINT" type="button" style="background-color:#1F88AB; color:#FFFFFF" value="Imprimir" ');

    pp.document.writeln('onclick=" location.reload(true);window.print();">');

    pp.document.writeln('<INPUT ID="CLOSE" type="button" style="background-color:#1F88AB; color:#FFFFFF" value="Cerrar" onclick="window.close();">');

    pp.document.writeln('</TD></TR><TR><TD></TD></TR></TABLE>');

    //Writing print area of the calling page

    pp.document.writeln(document.getElementById(print_area).innerHTML);

    //Ending Tag of </form>, </body> and </HTML>

    pp.document.writeln('</form></body></HTML>');

} 

